package game.physics;

import common.Rectangle;
import common.Vector;

public class CollisionSolution {
	{
		Displacement = new Vector();
	}
	public CollisionSolution() {
		NoSolution = Left = Right = Above = Below = true;
	}
	
	public CollisionSolution(Rectangle currentPos, Rectangle goodPos, Rectangle obstacle) {
		if(currentPos == null || goodPos == null || obstacle == null) {
			NoSolution = Left = Right = Above = Below = true;
			return;
		}
		
		NoSolution = false;
		
		Left = (obstacle.X + obstacle.Width <= goodPos.X);
		Right = (obstacle.X >= goodPos.X + goodPos.Width);
		Above = (obstacle.Y + obstacle.Height <= goodPos.Y);
		Below = (obstacle.Y >= goodPos.Y + goodPos.Height);
		
		Displacement.X = goodPos.X - currentPos.X;
		Displacement.Y = goodPos.Y - currentPos.Y;
		
	}
	public final boolean NoSolution;
	public final boolean Left;
	public final boolean Right;
	public final boolean Above;
	public final boolean Below;
	public final Vector Displacement;
}
